{include file="header.html"}
<script type="text/javascript" src="templates/js/jquery.colorbox.js" charset="utf-8"></script>
<link href="templates/style/colorbox.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" charset="utf-8" src="../htmleditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="../htmleditor/ueditor.all.min.js"> </script>
<!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
<script type="text/javascript" charset="utf-8" src="../htmleditor/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript">
$(function(){ 
    $('#article_form').validate({
        errorPlacement: function(error, element){
            $(element).next('.field_notice').hide();
            $(element).after(error);
        },
        success       : function(label){
            label.addClass('right').text('OK!');
        },
        rules : {    
            title : {
                required : true
            },
            name : {
                required : true
            },
            price:{
            	  required : true,
            	  number   : true
            },
            old_price:{
          	  required : true,
          	  number   : true
          },
      
          
          validityday:{        	  
        	  required : true, 
        	  number   : true
          },
         
            sort_order:{
               number   : true
            },
                       
             number:{
                number   : true
             },             
             pic : {
                accept  : 'gif|png|jpe?g'
            }
             
        },
        messages : {
            title : {
                required : '{$lang.title_empty}'
            },
            name : {
                required : '{$lang.name_empty}'
            },
            
            price:{            	
            	required : '价格不能为空',
            	 number   : '{$lang.number_only}'
            },
            old_price:{            	
            	required : '原价格不能为空',
            	 number   : '{$lang.number_only}'
            },
          
            validityday:{            	
            	required : '有效天数不能为空',
            	number   : '{$lang.number_only}'
            },
            pic : {
                accept : '{$lang.limit_img}'
            },
          
            number : {
                number   : '{$lang.number_only}'
            },
            sort_order  : {
                number   : '{$lang.number_only}'
            }
        }
    });
});


function add_coursetime(act,id){
	$w=$(window).width();
	$h=$(window).height();
	
	$w=$w*0.8;
	$("#tagframe").width($w);
	$("#tagframe").attr("src","index.php?app=course&act="+act+"&id="+id);
	$.colorbox({
		width : $w+50,
		height : "450px",
		inline : true,
		href : "#taglist"
	});
}

function edit_coursetime(act,id,course_id){
	$w=$(window).width();
	$h=$(window).height();
	
	$w=$w*0.8;
	$("#tagframe").width($w);
	$("#tagframe").attr("src","index.php?app=course&act="+act+"&id="+id+"&course_id="+course_id);
	$.colorbox({
		width : $w+10,
		height : "450px",
		inline : true,
		href : "#taglist"
	});
}

function set_coursetime(course_id){
	$w=$(window).width();
	$h=$(window).height();
	
	$w=$w*0.8;
	$("#tagframe").width($w);
	$("#tagframe").attr("src","index.php?app=course&act=set_coursetime&id="+course_id);
	$.colorbox({
		width : $w+10,
		height : "450px",
		inline : true,
		href : "#taglist"
	});
}

function add_coursefile(act,id,course_id){
	$w=$(window).width();
	$h=$(window).height();
	
	$w=$w*0.8;
	$("#tagframe").width($w);
	$("#tagframe").attr("src","index.php?app=course&act="+act+"&id="+id+"&course_id="+course_id);
	$.colorbox({
		width : $w+10,
		height : "450px",
		inline : true,
		href : "#taglist"
	});
}
</script>
<script type="text/javascript">
$(function(){
    $('#validity').datepicker({dateFormat: 'yy-mm-dd'});
    $('#validitystart').datepicker({dateFormat: 'yy-mm-dd'});
});
</script>
<div id="rightTop">
    <p>{$lang.key}</p>
    <ul class="subnav">
        <li><a class="btn1" href="index.php?app=course">{$lang.manage}</a></li>
        {if $course.course_id}
        <li><a class="btn1" href="index.php?app=course&amp;act=add">{$lang.add}</a></li>  
        {else}
        <li><span>{$lang.add}</span></li>
        {/if}
    </ul>
</div>



<div style="display: none"  >
	<div id="taglist"  >
	<iframe id="tagframe"  height="400px" width="600px" frameborder="0" scrolling="no"></iframe>
	</div>
</div>

<div class="info">
    <form method="post" enctype="multipart/form-data" id="article_form">
        <table class="infoTable">
            <tr>
                <th class="paddingT15">
                    标题:</th>
                <td class="paddingT15 wordSpacing5">
                {if  $course.noedit}
                {$course.name|escape}
                {else}
                    <input class="infoTableInput" id="name" type="text" name="name" value="{$course.name|escape}" />
                    {/if}
                </td>
            </tr>
              <tr>
                <th class="paddingT15">
                    副标题:</th>
                <td class="paddingT15 wordSpacing5">
                 {if  $course.noedit}
                {$course.title|escape}
                {else}
                    <input class="infoTableInput" id="title" type="text" name="title" value="{$course.title|escape}" />
                {/if}
                </td>
            </tr>
            
             <tr>
                <th class="paddingT15">
                    {$lang.price}:</th>
                <td class="paddingT15 wordSpacing5">
                {if  $course.noedit}
                 {$course.price|escape}
                   {else}
                    <input class="infoTableInput4" id="price" type="text" name="price" value="{$course.price|escape}" />
                     {/if}
                </td>
            </tr>
            
             <tr>
                <th class="paddingT15">
                    {$lang.old_price}:</th>
                <td class="paddingT15 wordSpacing5">
                 {if  $course.noedit}
                 {$course.old_price|escape}
                   {else}
                    <input class="infoTableInput4" id="old_price" type="text" name="old_price" value="{$course.old_price|escape}" />
                    {/if}
                </td>
            </tr>

         <tr>
                <th class="paddingT15">
                    <label for="cate_id">{$lang.cate}:</label></th>
                <td class="paddingT15 wordSpacing5">
                    <select id="cate" name="cate">
                    <option value="">请选择</option>
                    {html_options options=$dis_cat selected=$course.cate}
                    </select>
                </td>
            </tr>
            
         <tr style="display: none">
                <th class="paddingT15">
                    {$lang.validity}:</th>
                <td>
                 {if  $course.noedit}
                 {$course.validitystart|escape}-
                  {$course.validity|escape}
                   {else}
                  <input class="infoTableInput4" type="text" value="{$course.validitystart}" id="validitystart" name="validitystart" class="pick_date"  size="10"/>
                  - <input class="infoTableInput4" type="text" value="{$course.validity}" id="validity" name="validity" class="pick_date"   size="10"/>
                  {/if}
                </td>
            </tr>
      
        
         <tr>
                <th class="paddingT15">
                    图片:</th>
                <td class="paddingT15 wordSpacing5">
                {if $course.pic}
                 <a href="/{$course.pic}" target="_blank"><img src="/{$course.pic}" class="makesmall" max_width="120" max_height="90" /></a>
                {/if}
                    <input class="infoTableFile2" id="pic" type="file" name="pic" />471&nbsp;X&nbsp;307
                    <label class="field_notice">{$lang.limit_img}</label>
                </td>
            </tr>            
            
            
               <tr style="display: none">
                <th class="paddingT15">
                    {$lang.tags}:</th>
                <td class="paddingT15 wordSpacing5">
                    {if  $course.noedit}
                 {$course.tags|escape}                
                   {else}
                     <input   class="infoTableInput" id="tags" name="tags"   value="{$course.tags}">
                     {/if}
                </td>
            </tr>
            
               <tr>
                <th class="paddingT15">
                    {$lang.fit}:</th>
                <td class="paddingT15 wordSpacing5">
                {if  $course.noedit}
                 {$course.fit|escape}                
                   {else}
                     <textarea id="fit" name="fit" style="width:250px;height:100px;">{$course.fit}</textarea>
                     {/if}
                </td>
            </tr> 
            
            
            <tr>
                <th class="paddingT15">
                    <label for="article">{$lang.description}:</label></th>
                <td class="paddingT15 wordSpacing5">
                  {if  $course.noedit}
                 {$course.description|escape}                
                   {else} 
                    <textarea id="description" name="description" style="width:650px;height:200px;">{$course.description|escape}</textarea>
                 {/if}
<script type="text/javascript">
    //实例化编辑器
    //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
    var ue = UE.getEditor('description');
</script>
                </td>
            </tr>
             
             
            
            <tr>
                <th class="paddingT15">
                    {$lang.outline}:</th>
                <td class="paddingT15 wordSpacing5">
                   {if  $course.noedit}
                 {$course.outline|escape}                
                   {else}                   
                     <textarea id="outline" name="outline" style="width:650px;height:200px;">{$course.outline}</textarea>
                     <script type="text/javascript">
				    var ue = UE.getEditor('outline');
				   </script>                     
                     {/if}
                </td>
            </tr>  
            
            {if $smarty.get.act!='add'}
              <tr style="display: none">
                <th class="paddingT15">
                    {$lang.add_time}:</th>
                <td class="paddingT15 wordSpacing5">
                    {$course.add_time|date:complete}
                </td>
            </tr>   	

           <tr style="display: none">
                <th class="paddingT15" >
                    {$lang.uid}:</th>
                <td class="paddingT15 wordSpacing5">
                   <a href="index.php?app=user&act=edit&id={$course.user_id}">{$course.user_name|escape}</a>
                </td>
            </tr>   
            {/if}
            	
              <tr style="display: none">
                <th class="paddingT15">
                    {$lang.number}:</th>
                <td class="paddingT15 wordSpacing5">
                   {if  $course.noedit}
                   {$course.number}               
                   {else} 
                    <input class="sort_order" id="number" type="text" name="number" value="{$course.number}" />
                    {/if}
                     <label class="field_notice"></label>
                </td>
            </tr>
            <tr style="display: none">
                <th class="paddingT15">
                    上课时间 :</th>
                <td class="paddingT15 wordSpacing5">
                 
                  <select name="hourstart"><option value="">{$lang.select_please}</option>
               {html_options options=$h selected=$course.hourstart}
              </select>
              <select name="hourstartm"><option value="">{$lang.select_please}</option>
               {html_options options=$s selected=$course.hourstartm}
              </select> 至 <select name="hourend"><option value="">{$lang.select_please}</option>
               {html_options options=$h selected=$course.hourend}
              </select>
              <select name="hourendm"><option value="">{$lang.select_please}</option>
               {html_options options=$s selected=$course.hourendm}
              </select>
                 <label class="field_notice"></label>
                </td>
            </tr>  
             
             
             
                <tr>
                <th class="paddingT15">
                    {$lang.lessons}:</th>
                <td class="paddingT15 wordSpacing5">
                  {if  $course.noedit}
                 {$course.lessons|escape}                
                   {else} 
                     <input class="sort_order" id="lessons" type="text" name="lessons" value="{$course.lessons}" />
                     {/if}
                </td>
            </tr>
            
            
                <tr>
                <th class="paddingT15">
                    {$lang.validityday}:</th>
                <td class="paddingT15 wordSpacing5">
                  {if  $course.noedit}
                 {$course.validityday|escape}                
                   {else} 
                     <input class="sort_order" id="validityday" type="text" name="validityday" value="{$course.validityday}" />
                     {/if}
                     <label class="field_notice">购买客户可查看时间,0为不限制</label>
                </td> 
                
            </tr>
            
            
            
            
            <tr>
                <th class="paddingT15">
                    {$lang.isopen}:</th>
                <td class="paddingT15 wordSpacing5">                             
                     <input name="isopen" type="checkbox" id="isopen" value="1" {if $course.isopen}checked{/if} />
                </td>
            </tr>
                <tr>
                <th class="paddingT15">
                    {$lang.sort_order}:</th>
                <td class="paddingT15 wordSpacing5">
                   {if  $course.noedit}
                 {$course.sort_order|escape}                
                   {else} 
                    <input class="sort_order" id="sort_order" type="text" name="sort_order" value="{$course.sort_order}" />
                    {/if}
                       <label class="field_notice"></label>
                </td>
            </tr> 
              	

 
           {if  $course.noedit!=1}  
        <tr>
            <th></th>
            <td class="ptb20">
                <input class="formbtn" type="submit" name="Submit" value="{$lang.submit}" />
                <input class="formbtn" type="reset" name="Submit2" value="{$lang.reset}" />
            </td>
        </tr>
        {/if}
        </table>
    </form>
</div>
<!-- {if $course.course_id} -->
<form method="post" enctype="multipart/form-data" id="shopassistant_forms">
<div id="rightTop">
  <p><b>课程课时</b>  </p>
   {if  $course.noedit!=1}
   <a  class="btn1" onclick="set_coursetime({$course.course_id})"   href="javascript:;" style="float:left; margin:15px 5px 0 5px">配置课时</a>
   <a  class="btn1"  onclick="add_coursetime('timeadd',{$course.course_id})"   href="javascript:;"    style="float:left; margin:15px 5px 0 5px">添加课时</a>
    <a  class="btn1"     href="index.php?app=course&act=alldel_coursetime&id={$course.course_id}" onclick="javaScript:return confirm('您确定要全部清除吗？')" style="float:left; margin:15px 5px 0 5px">清除课时</a>  

  {/if}

</div>
<div style="clear:both"></div>
<div class="tdare">
 <table width="100%" cellspacing="0" class="dataTable">
    <!--{if $coursetime_list}-->
    <tr class="tatr1">
      <td width="150" class="firstCell"> 课时</td>   
       <td>开始时间</td>
       <td>结束时间</td>   
        <td>日期</td> 
         <td>备注</td> 
    {if  $course.noedit!=1}
      <td class="handler">{$lang.handler}</td>
      {/if}
    </tr>
    <!--{/if}-->
    <!--{foreach from=$coursetime_list item=coursetime}-->
    <tr class="tatr2">
      <td class="firstCell"  width="150">
      <input type="checkbox" class="checkitem"  value="{$coursetime.ct_id}" />&nbsp;&nbsp;&nbsp;{$coursetime.lessons}</td>
    <td>{if $coursetime.hourstart}{$coursetime.hourstart}{else}0{/if}点{if $coursetime.hourstartm}{$coursetime.hourstartm}{else}0{/if}分</td>
    <td> {if $coursetime.hourend}{$coursetime.hourend}{else}0{/if}点{$coursetime.hourendm}分</td>
        <td> {$coursetime.take_date}</td>
         <td> {$coursetime.note|truncate:20}</td>
     {if  $course.noedit!=1}
      <td class="handler">
      <span style="width: 100px">      
        <a   onclick="edit_coursetime('edit_coursetime',{$coursetime.ct_id},{$course.course_id})"   href="javascript:;"   >编辑</a>
      |
   <a href="index.php?app=course&act=drop_coursetime&id={$coursetime.ct_id}&course_id={$course.course_id}" onclick="javaScript:return confirm('您确定要删除吗？')">删除</a>
      </span>
      </td>
       {/if}
    </tr>
    <!--{foreachelse}-->
    <tr class="no_data">
      <td colspan="10">{$lang.no_data}</td>
    </tr>
    <!--{/foreach}-->
  </table>
  </div>
     {if  $course.noedit!=1}
    <!--{if $coursetime_list}-->
  <div id="dataFuncs">
  <div id="batchAction" class="left paddingT15"> &nbsp;&nbsp;
      <input class="formbtn batchButton" type="button" value="删除" name="id" uri="index.php?app=course&act=drop_coursetime&course_id={$course.course_id}" presubmit="confirm('确定要删除？');" />
    </div>
    <div class="pageLinks">{$fenye}</div>
    <div class="clear"></div>
  </div>
  <!--{/if}-->
  {/if}
  </form>
{/if}



<br/>
<br/>

<!-- {if $course.course_id} -->
<form method="post" enctype="multipart/form-data" id="shopassistant_forms">
<div id="rightTop">
  <p><b>课程附件</b></p>
   {if  $course.noedit!=1}
  <a  class="btn1"  onclick="add_coursefile('add_coursefile',{$course.course_id})"   href="javascript:;"    style="float:left; margin:15px 20px 0 20px">添加附件</a>
  {/if}
</div>
<div style="clear:both"></div>

<div class="tdare">
 <table width="100%" cellspacing="0" class="dataTable">
    <!--{if $coursefile_list}-->
    <tr class="tatr1">
      <td width="350" class="firstCell">名称</td>   
       <td>文件类型</td>
       <td>添加时间</td>
       <td>附近</td>
       <td>排序</td>   
        
    {if  $course.noedit!=1}
      <td class="handler">{$lang.handler}</td>
      {/if}
    </tr>
    <!--{/if}-->
    <!--{foreach from=$coursefile_list item=courfile}-->
    <tr class="tatr2">
      <td class="firstCell"  width="150">
      <input type="checkbox" class="checkitem"  value="{$courfile.file_id}" />&nbsp;&nbsp;&nbsp;{$courfile.name}</td>
      <td>{$courfile.type}</td>
    <td>{$courfile.add_time}</td>
    <td> 
    {if  $course.noedit!=1}
    <span ectype="inline_edit" fieldname="filesort_order" fieldid="{$courfile.file_id}" datatype="pint" maxvalue="255" class="editable">{$courfile.sort_order}</span>
    {else}
    {$courfile.sort_order}
    {/if}
    </td>  
    <td> {if $courfile.path}<a href="{$courfile.path}" target="_blank">查看附件</a>{/if}</td>
     {if  $course.noedit!=1}
      <td class="handler">
      <span style="width: 100px">      
        <a   onclick="add_coursefile('edit_coursefile',{$courfile.file_id},{$course.course_id})"   href="javascript:;">编辑</a> |
   <a href="index.php?app=course&act=drop_coursefile&id={$courfile.file_id}&course_id={$course.course_id}" onclick="javaScript:return confirm('您确定要删除吗？')">删除</a>
      </span>
      </td>
       {/if}
    </tr>
    <!--{foreachelse}-->
    <tr class="no_data">
      <td colspan="10">{$lang.no_data}</td>
    </tr>
    <!--{/foreach}-->
  </table>
  </div>
     {if  $course.noedit!=1}
    <!--{if $coursefile_list}-->
  <div id="dataFuncs">
  <div id="batchAction" class="left paddingT15"> &nbsp;&nbsp;
      <input class="formbtn batchButton" type="button" value="删除" name="id" uri="index.php?app=course&act=drop_coursefile&course_id={$course.course_id}" presubmit="confirm('确定要删除？');" />
    </div>
    <div class="pageLinks">{$fenyefile}</div>
    <div class="clear"></div>
  </div>
  <!--{/if}-->
  {/if}
  </form>
{/if}


{include file="footer.html"}
